home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / sysext / init / bombshel.sit / Bomb Shelter.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-22  |  1.6 KB  |  102 lines

  1. /* ###################################################################
  2.  
  3. Bomb Shelter by Andrew Welch
  4.  
  5. This INIT was written at the request of some of my shareware users.
  6. It simply patches _InitDialogs and inserts a ResumeProc if there
  7. isn't one specified.
  8.  
  9. The ResumeProc simply does an _ExitToShell.
  10.  
  11. ################################################################### */
  12.  
  13.  
  14. #define    JMP                0x4EF9
  15. #define    InitDialogsTrap    0xA97B
  16.  
  17.  
  18. main()
  19. {
  20.     asm
  21.     {
  22.         lea        @savedG,A1
  23.         move.l    A0, (A1)
  24.         _RecoverHandle
  25.         move.l    A0,-(SP)
  26.         _DetachResource
  27.  
  28. /* Patch InitDialogs */
  29.  
  30.         move     #InitDialogsTrap,D0
  31.         _GetTrapAddress    NEWTOOL
  32.  
  33.         lea        @origInitDialogs,A1
  34.         move    #JMP,(A1)+
  35.         move.l    A0,(A1)
  36.  
  37.         move     #InitDialogsTrap,D0
  38.         lea        @patchInitDialogs,A0
  39.         _SetTrapAddress    NEWTOOL
  40.  
  41. /* Do the Show Icon code */
  42.  
  43.         clr.l    -(SP)
  44.         move.l    #'Show',-(SP)
  45.         move.w    #0,-(SP)
  46.         _GetResource
  47.         tst.l    (SP)
  48.         move.l    (SP)+,A0
  49.         beq        @skipShow
  50.         lea        @showCR,A1
  51.         move.l    A0,(A1)
  52.         _HNoPurge
  53.         _HLock
  54.         move.l    (A0),A0
  55.         jsr    (A0)
  56.         move.l    @showCR,A0
  57.         _HPurge
  58.         _HUnlock
  59.  
  60. @skipShow
  61.  
  62.         rts
  63.  
  64.  
  65. /* ################################################################### */
  66.  
  67. /* Here is our Resume Procedure */
  68.  
  69. @ResumeProc
  70.  
  71.         _ExitToShell
  72.  
  73.  
  74. /* ################################################################### */
  75.  
  76. /* Here is our patch to InitDialogs */
  77.  
  78. @patchInitDialogs
  79.  
  80.         tst.l    4(SP)
  81.         bne        @alreadyInstalled
  82.  
  83.         lea        @ResumeProc,A0
  84.         move.l    A0,4(SP)
  85.  
  86. @alreadyInstalled
  87.  
  88. @origInitDialogs
  89.  
  90.         nop
  91.         nop
  92.         nop
  93.  
  94.  
  95. /* ################################################################### */
  96.  
  97. /* Static storage */
  98.  
  99. @savedG        dc.l    0            /* PTR to our code */
  100. @showCR        dc.l    0            /* Holds the ShowIcon code handle */
  101.     }
  102. }